package config

import (
	"github.com/shima-park/agollo"
	"strconv"
)

type ServerConfig struct {
	RunMode string
	HttpPort int
	ReadTimeout int
	WriteTimeOut int
}

const (
	FlagServerRunMode = "server.run.mode"
	FlagHttpPort = "server.http.port"
	FlagReadTimeout = "server.read.timeout"
	FlagWriteTimeOut = "server.write.timeout"
)


func GetServerConfig() ServerConfig {
	httpPort, _ := strconv.Atoi(agollo.Get(FlagHttpPort))
	readTimeout, _ := strconv.Atoi(agollo.Get(FlagReadTimeout))
	writeTimeout, _ := strconv.Atoi(agollo.Get(FlagWriteTimeOut))

	return ServerConfig{
		RunMode:      agollo.Get(FlagServerRunMode),
		HttpPort:     httpPort,
		ReadTimeout:  readTimeout,
		WriteTimeOut: writeTimeout,
	}
}